#include <cstdio>
#include <fcntl.h>
#include <google/protobuf/text_format.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include "operations.pb.h"
#include "internal.pb.h"

class ProtoManager {
    public:
        ProtoManager(const Operation&, const int);
		std::vector<internal::TaskList*> getStripes();
        internal::InputOperation* getResultTypes(const Operation&) const;

    private:
        int numberOfWorkers;
        Operation preliminaryProto;
        std::vector<internal::TaskList*> stripes;
        std::vector<internal::Operation*> currNodes;

        void sliceOperation(const Operation&, const int);
        void sliceScan(const ScanOperation&, const int);
        void sliceCompute(const ComputeOperation&, const int);
        void sliceFilter(const FilterOperation&, const int);
        void sliceGroupBy(const GroupByOperation&, const int);
        
        void copyExpression(const Expression& se, internal::Expression* const de);
        internal::InputOperation_Type getTypeOfExpression(const Expression&,
            const internal::InputOperation* const) const;

        void printStripe(const ::google::protobuf::Message&, const int) const;
};
